package o;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;

public final class erw extends erz {
    public static boolean ˏ(Context context) {
        if (context == null) {
            return false;
        }
        return ˊ(context, context.getPackageName());
    }

    public static boolean ˊ(Context context, String str) {
        if (context == null) {
            return false;
        }
        return ˎ(context.getPackageManager(), str);
    }

    public static boolean ˎ(PackageManager packageManager, String str) {
        if (packageManager == null || str == null || str.length() == 0) {
            return false;
        }
        try {
            ApplicationInfo applicationInfo = packageManager.getApplicationInfo(str, 0);
            if (applicationInfo == null) {
                return false;
            }
            if (ˏ(applicationInfo) || ˎ(applicationInfo)) {
                return true;
            }
            return false;
        } catch (NameNotFoundException e) {
            Logger.ˋ(PackageUtils.TAG, "isSystemApplication" + e.toString());
            return false;
        }
    }

    public static boolean ˏ(ApplicationInfo applicationInfo) {
        return (applicationInfo.flags & DnsConfig.MAX_CACHE_ENTRIES) != 0;
    }

    public static boolean ˎ(ApplicationInfo applicationInfo) {
        return (applicationInfo.flags & 1) != 0;
    }

    public static String ˏ(PackageManager packageManager, String str) {
        String str2 = null;
        try {
            str2 = packageManager.getInstallerPackageName(str);
        } catch (IllegalArgumentException e) {
            if (Logger.ˎ()) {
                Logger.ˏ(PackageUtils.TAG, "can not find installer pkg." + str);
            }
        }
        return str2;
    }
}
